<?php

/**
 * This is the model class for table "matching_history".
 *
 * The followings are the available columns in table 'matching_history':
 * @property integer $matching_history_id
 * @property integer $member_id
 * @property string $username
 * @property double $aPoint
 * @property double $bPoint
 * @property double $matching_slot
 * @property string $package
 * @property double $package_price
 * @property double $package_point
 * @property double $max_point
 * @property double $earned_amount
 * @property double $newAPoint
 * @property double $newBPoint
 * @property string $date
 */
class MatchingHistory extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return MatchingHistory the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'matching_history';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('member_id', 'numerical', 'integerOnly'=>true),
			array('aPoint, bPoint, matching_slot, package_price, package_point, max_point, earned_amount, newAPoint, newBPoint', 'numerical'),
			array('username, package', 'length', 'max'=>255),
			array('date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('matching_history_id, member_id, username, aPoint, bPoint, matching_slot, package, package_price, package_point, max_point, earned_amount, newAPoint, newBPoint, date', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'matching_history_id' => 'Matching History',
			'member_id' => 'Member',
			'username' => 'Username',
			'aPoint' => 'A Point',
			'bPoint' => 'B Point',
			'matching_slot' => 'Matching Slot',
			'package' => 'Package',
			'package_price' => 'Package Price',
			'package_point' => 'Package Point',
			'max_point' => 'Max Point',
			'earned_amount' => 'Earned Amount',
			'newAPoint' => 'New Apoint',
			'newBPoint' => 'New Bpoint',
			'date' => 'Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('matching_history_id',$this->matching_history_id);
		$criteria->compare('member_id',$this->member_id);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('aPoint',$this->aPoint);
		$criteria->compare('bPoint',$this->bPoint);
		$criteria->compare('matching_slot',$this->matching_slot);
		$criteria->compare('package',$this->package,true);
		$criteria->compare('package_price',$this->package_price);
		$criteria->compare('package_point',$this->package_point);
		$criteria->compare('max_point',$this->max_point);
		$criteria->compare('earned_amount',$this->earned_amount);
		$criteria->compare('newAPoint',$this->newAPoint);
		$criteria->compare('newBPoint',$this->newBPoint);
		$criteria->compare('date',$this->date,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}